package io.ent.modules.file.controller;

import io.ent.modules.file.entity.Param;
import io.ent.modules.file.service.FileService;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import javax.imageio.ImageIO;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.util.HashMap;

@Controller
@RequestMapping("/file")
public class FileController {
	@Resource
	private FileService fileService;
	
	/**
	 * 上传文件
	 * @param request
	 * @param param
	 * @return
	 * @throws IllegalStateException
	 * @throws IOException
	 */
	@ResponseBody
	@RequestMapping("/upload")
	public String upload(HttpServletRequest request, Param param)  throws IllegalStateException, IOException {
		return fileService.upload(request, param);
	}
	
	/**
	 * 删除文件
	 * @param request
	 * @param param
	 * @return
	 */
	@ResponseBody
	@RequestMapping("/delete")
	public String delete(HttpServletRequest request, Param param){

		return fileService.delete(request, param);
	}

}